<?php

include '../../db.php';
$connect = pg_connect($connectionString);
if (!$connect) {
    echo "connect : A connection to the server could not be established!";
    return false;
}

//$queryString = "SELECT id, name,ruc,address,contact,phone FROM sale_client LIMIT 10 OFFSET " . ($_GET["pag"]*10);
$queryString = "SELECT id, name,ruc,address,contact,phone,fullname FROM sale_client WHERE fullname LIKE '%".$_GET['word_search']."%' LIMIT 10 OFFSET " . ($_GET["pag"]*10);


$query = pg_query($connect, $queryString);
if (!$query) {
    echo 'query : ';
    return false;
}
$arrRegistros = pg_fetch_all($query);
echo json_encode($arrRegistros);
$num_fields = pg_num_fields($query);
$num_rows = pg_num_rows($query);

pg_close($connect);
